package com.xzlf;

import java.awt.*;
import java.awt.image.BufferedImage;

public class ImageUtil {
    public static BufferedImage rotateImage(final BufferedImage bufferedImage, final int degree) {
        int width = bufferedImage.getWidth();
        int height = bufferedImage.getHeight();
        int transparency = bufferedImage.getColorModel().getTransparency();
        BufferedImage image = new BufferedImage(width, height, transparency);
        Graphics2D graphics = image.createGraphics();
        graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
        graphics.rotate(Math.toRadians(degree), width / 2, height / 2);
        graphics.drawImage(bufferedImage, 0, 0, null);
        graphics.dispose();
        return image;
    }
}
